import type {BasicColumn, FormSchema} from '@/components/Table'
import {useRender} from '@/components/Table'
import {DICT_TYPE, getDictOptions} from "@/utils/dict";

export const columns: BasicColumn[] = [
  {
    title: '编号',
    dataIndex: 'id',
    width: 80
  },
  {
    title: '单号',
    dataIndex: 'orderId',
    width: 160
  },
  {
    title: '外部单号',
    dataIndex: 'outOrderId',
    width: 160
  },
  {
    title: 'appId',
    dataIndex: 'appId',
    width: 90
  },
  {
    title: '手机号',
    dataIndex: 'phone',
    width: 120
  },
  {
    title: '归属地',
    dataIndex: 'geoInfo',
    width: 150
  },
  {
    title: '状态',
    dataIndex: 'status',
    width: 140
  },
  {
    title: '附加状态',
    dataIndex: 'extStatus',
    width: 100
  },
  {
    title: '回调数据',
    dataIndex: 'callbackData',
    width: 160
  },
  {
    title: '通知数据',
    dataIndex: 'notifyData',
    width: 160
  },
  {
    title: '额外数据',
    dataIndex: 'data',
    width: 160
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 180,
    customRender: ({ text }) => {
      return useRender.renderDate(text)
    },
  },
  {
    title: '更新时间',
    dataIndex: 'updateTime',
    width: 180,
    customRender: ({ text }) => {
      return useRender.renderDate(text)
    },
  },
]

export const searchFormSchema: FormSchema[] = [
  {
    label: '手机号',
    field: 'phone',
    component: 'Input',
    colProps: { span: 6 }
  },
  {
    label: 'appId',
    field: 'appId',
    component: 'Select',
    componentProps: {
      options: getDictOptions(DICT_TYPE.appEnum, 'string'),
      mode: "multiple"
    },
    colProps: { span: 6 }
  },
  {
    label: '状态',
    field: 'status',
    component: 'Select',
    componentProps: {
      options: getDictOptions(DICT_TYPE.orderStatus, 'string'),
      mode: "multiple"
    },
    colProps: {span: 6}
  },
  {
    label: '附加状态',
    field: 'extStatus',
    component: 'Select',
    componentProps: {
      options: getDictOptions(DICT_TYPE.extStatus, 'string'),
      mode: "multiple",
    },
    colProps: {span: 6}
  },
  {
    label: '系统单号',
    field: 'orderId',
    component: 'Input',
    colProps: { span: 6 }
  },
  {
    label: '外部单号',
    field: 'outOrderId',
    component: 'Input',
    colProps: { span: 6 }
  },
  {
    label: '创建时间',
    field: 'createTime',
    component: 'RangePicker',
    componentProps: {
      showTime: true,
      format: 'YYYY-MM-DD HH:mm:ss',
      // valueFormat: 'x',
    },
    colProps: {span: 8}
  },
  {
    label: '更新时间',
    field: 'updateTime',
    component: 'RangePicker',
    componentProps: {
      showTime: true,
      format: 'YYYY-MM-DD HH:mm:ss',
      // valueFormat: 'x',
    },
    colProps: {span: 8}
  },
]

export const createFormSchema: FormSchema[] = [
  {
    label: '编号',
    field: 'id',
    show: false,
    component: 'Input'
  },
  {
    label: '单号',
    field: 'orderId',
    required: true,
    component: 'Input'
  },
  {
    label: '外部单号',
    field: 'outOrderId',
    required: true,
    component: 'Input'
  },
  {
    label: '业务code',
    field: 'bizId',
    required: true,
    component: 'Input'
  },
  {
    label: 'appId',
    field: 'appId',
    required: true,
    component: 'Input'
  },
  {
    label: '手机号',
    field: 'phone',
    component: 'Input'
  },
  {
    label: '状态',
    field: 'status',
    component: 'RadioButtonGroup',
    componentProps: {
        options:[],
    }
  },
  {
    label: '上游回调数据',
    field: 'callbackData',
    component: 'Input'
  },
  {
    label: '通知下游数据',
    field: 'notifyData',
    component: 'Input'
  },
  {
    label: '存储配置',
    field: 'data',
    component: 'Input'
  },
]

export const updateFormSchema: FormSchema[] = [
  {
    label: '编号',
    field: 'id',
    show: false,
    component: 'Input'
  },
  {
    label: '单号',
    field: 'orderId',
    required: true,
    component: 'Input'
  },
  {
    label: '外部单号',
    field: 'outOrderId',
    required: true,
    component: 'Input'
  },
  {
    label: '业务code',
    field: 'bizId',
    required: true,
    component: 'Input'
  },
  {
    label: 'appId',
    field: 'appId',
    required: true,
    component: 'Input'
  },
  {
    label: '手机号',
    field: 'phone',
    component: 'Input'
  },
  {
    label: '状态',
    field: 'status',
    component: 'RadioButtonGroup',
    componentProps: {
      options:[],
    }
  },
  {
    label: '上游回调数据',
    field: 'callbackData',
    component: 'Input'
  },
  {
    label: '通知下游数据',
    field: 'notifyData',
    component: 'Input'
  },
  {
    label: '存储配置',
    field: 'data',
    component: 'Input'
  },
]
